const App = getApp();
Page({
    data: {
        imgUrl:App.globalData.imgUrl,
        isChooseShow:true,
        isLoading: false,
        reLoading: false,
        list: [
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          },
          {
            name:"李先生",
            phone:15022224777,
            money:77,
            nums:128
          }
        ],
        total:0,
        page:1
    },
    onLoad: function (options) {
        
    },
    toDetail(e) {
        let _this = this;
        let key = e.currentTarget.dataset.key;
        wx.navigateTo({
            url: '/pages/generate/detail?key=' + key,
        });
    },
    onShow(){
      this.getMyEmptyCodeList();
   },
     // 获取赋能记录
     getMyEmptyCodeList() {
      let _this = this;
      App._get('Emptyqrcodec/getMyEmptyCodeList', {page:this.data.page}, res => {
          if(_this.data.page>1){
              _this.setData({
                  list: _this.data.list.concat(res.data.list),
                  total: res.data.count
              })
          }else{
              _this.setData({
                  list: res.data.list,
                  total: res.data.count
              })
          }           
      }, false, () => {
          _this.setData({
              isLoading: false,
              reLoading: false,
          })
      })
  },
     /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
      this.ajaxloading = this.selectComponent("#ajax_loading");
      if (this.data.list.length >= this.data.total) {
          this.ajaxloading.AjaxLoading(true);
          this.ajaxloading.AjaxNoresult(false);
          return false;
      }
      this.setData({
          page:this.data.page+1
      })
      this.getMyEmptyCodeList();
      this.ajaxloading.AjaxLoading(false);
  },
    toChoose(e){
        let _this = this;
        let id = e.currentTarget.dataset.id;
        console.log(id)
        this.setData({
          isChooseShow: true
        }) 
    },
    toJump(e){
        let key = e.currentTarget.dataset.key;
        console.log(key)
        this.setData({
            isChooseShow: false
        })
        // wx.navigateTo({
        //     url: '/pages/generate/replace?key=' + key,
        // });
    },
    // 关闭提示
    onChooseClose() {
    this.setData({
      isChooseShow: false
    })
  }
});
